package testguo;

import java.util.Arrays;

public class Liku02 {
    public static void main(String[] args) {
        //给定一个数组nums，返回数组中任意两个数之和等于目标值target的索引
        int[] arr=twoSun(new int[]{2,3,4},6);
        //printArrayData(arr);
        System.out.println(Arrays.toString(arr));
    }
    public static int[] twoSun(int[] arr,int target){
        //int[] result=new int[2];
        for (int i=0;i<arr.length;i++){
            for (int j=i+1;j<arr.length;j++){
                if (arr[i]+arr[j]==target){
                    /*result[0]=i;
                    result[1]=j;*/
                    return new int[]{i,j};
                }
            }
        }
        return new int[0];
    }
    public static void printArrayData(int[] arr){
        for (int i=0;i<arr.length;i++){
            System.out.print(arr[i]+"\t");
        }
    }
}
